package com.e3.basdoc.employee.service;

import java.util.List;

import com.e3.basdoc.employee.model.EmployeeModel;
import com.e3.core.base.ServiceLocator;
import com.e3.core.cache.CacheLoader;

public class EmployeeCacheLoader implements CacheLoader {
	
	private EmployeeQueryService employeeQueryService;
	
	private EmployeeQueryService getEmployeeQueryService(){
		if(employeeQueryService == null){
			employeeQueryService = ServiceLocator.getQueryService(EmployeeQueryService.class);
		}
		return employeeQueryService;
	}

	public void loadeData() throws Exception {
		List<EmployeeModel> models = getEmployeeQueryService().getAllEmployees();
		if(models==null||models.isEmpty()){
			return;
		}
		for (EmployeeModel model : models) {
			EmployeeCacheManager.INSTANCE.put(model);
		}

	}

}
